export default {
  data() {
    return {
      checkAll: false,
      // isIndeterminate: false,
      'formData.mp_ids': []
    }
  },
  computed: {
    _tencentList() {
      if (!this.keyword) {
        return this.tencentList
      }
      return this.tencentList.filter(item => {
        return item.label && item.label.indexOf(this.keyword) > -1
      })
    },
    mpOptions() {
      return this.tencentList.map(item => {
        return item.value
      })
    },
    isIndeterminate() {
      if (!this.formData.mp_ids) return false
      const checkedCount = this.formData.mp_ids.length
      return checkedCount > 0 && checkedCount < this.tencentList.length
    }
  },
  methods: {
    handleCheckAllChange(val) {
      const { mpOptions } = this
      this.formData.mp_ids = val ? mpOptions : []
      // this.isIndeterminate = false
    },
    handleListCheckChange(value) {
      let checkedCount = value.length
      this.checkAll = checkedCount === this.tencentList.length
      // this.isIndeterminate = checkedCount > 0 && checkedCount < this.tencentList.length
    }
  }
}
